********************************************************************************
** REPLICATION SYNTAX FILE 2
** USE THIS FILE TO RESHAPE PANEL INTO LONG FORMAT AND REPLICATE RESULTS OF ANALYSES OF PANEL IN LONG FORMAT
********************************************************************************

*Load data file
use "masterfile_wide.dta", clear

********************************************************************************
** RECODES
********************************************************************************

gen newcov1_w1 = 0 if q57_w1 <= 2
replace newcov1_w1 = 1 if q57_w1 == 1
gen newcov1_w2 = 0 if q57_w2 <= 2 | q169_w2 <= 2 | (q0_w2 == 1 & q57_w1 == 1)
replace newcov1_w2 = 1 if q169_w2 == 1
gen newcov1_w3 = 0 if q57_w3 <= 2 | q169a_w3 <= 2 | q169b_w3 <= 2 | (q0_w3 == 1 & q57_w1 == 1) | (q0_w3 == 1 & q57_w2 == 1)
replace newcov1_w3 = 1 if q169a_w3 == 1 | q169b_w3 == 1
gen newcov1_w4 = 0 if q57_w4 <= 2 | q169a_w4 <= 2 | q169b_w4 <= 2 | q169c_w4 <= 2 | (q0_w4 == 1 & q57_w1 == 1) | (q0_w4 == 1 & q57_w2 == 1) | (q0_w4 == 1 & q57_w3 == 1)
replace newcov1_w4 = 1 if q169a_w4 == 1 | q169b_w4 == 1 | q169c_w4 == 1
gen newcov1_w5 = 0 if q57_w5 <= 2
replace newcov1_w5 = 1 if q169_w5 == 1 & q57_w5 == 1

gen newpay_w1 = 0 if q60_w1 <= 2
replace newpay_w1 = 1 if q60_w1 == 1
gen newpay_w2 = 0 if q60_w2 <= 2 | q172_w2 <= 2
replace newpay_w2 = 1 if q172_w2 == 1
gen newpay_w3 = 0 if q60_w3 <= 2 | q172a_w3 <= 2 | q172b_w3 <= 2 
replace newpay_w3 = 1 if q172a_w3 == 1 | q172b_w3 == 1
gen newpay_w4 = 0 if q60_w4 <= 2 | q172a_w4 <= 2 | q172b_w4 <= 2 | q172c_w4 <= 2 
replace newpay_w4 = 1 if q172a_w4 == 1 | q172b_w4 == 1 | q172c_w4 == 1
gen newpay_w5 = 0 if q60_w5 <= 2
replace newpay_w5 = 1 if q60_w5 == 1 & q172_w5 == 1

gen newdiehh_w1 = 0 if q66_w1 <= 9 | q166_w1 == 1
replace newdiehh_w1 = 1 if q66_w1 == 1
gen newdiehh_w2 = 0 if q66_w2 <= 2 | q178_w2 <= 2 | q166_w2 == 1
replace newdiehh_w2 = 1 if q178_w2 == 1
gen newdiehh_w3 = 0 if q66_w3 <= 2 | q178a_w3 <= 2 | q178b_w3 <= 2 | q166_w3 == 1
replace newdiehh_w3 = 1 if q178a_w3 == 1 | q178b_w3 == 1
gen newdiehh_w4 = 0 if q66_w4 <= 2 | q178a_w4 <= 2 | q178b_w4 <= 2 | q178c_w4 <= 2 | q166_w4 == 1
replace newdiehh_w4 = 1 if q178a_w4 == 1 | q178b_w4 == 1 | q178c_w4 == 1
gen newdiehh_w5 = 0 if q66_w5 <= 9 | q166_w5 == 1
replace newdiehh_w5 = 1 if q66_w5 == 1 & q178_w5 == 1

gen newjobhh_w1 = 0 if q67_w1 <= 9 | q166_w1 == 1
replace newjobhh_w1 = 1 if q67_w1 == 1
gen newjobhh_w2 = 0 if q67_w2 <= 2 | q179_w2 <= 2 | q166_w2 == 1
replace newjobhh_w2 = 1 if q179_w2 == 1
gen newjobhh_w3 = 0 if q67_w3 <= 2 | q179a_w3 <= 2 | q179b_w3 <= 2 | q166_w3 == 1
replace newjobhh_w3 = 1 if q179a_w3 == 1 | q179b_w3 == 1
gen newjobhh_w4 = 0 if q67_w4 <= 2 | q179a_w4 <= 2 | q179b_w4 <= 2 | q179c_w4 <= 2 | q166_w4 == 1
replace newjobhh_w4 = 1 if q179a_w4 == 1 | q179b_w4 == 1 | q179c_w4 == 1
gen newjobhh_w5 = 0 if q67_w5 <= 9 | q166_w5 == 1
replace newjobhh_w5 = 1 if q67_w5 == 1 & q179_w5 == 1

gen newdieany_w1 = 0 if q72_w1 <= 2
replace newdieany_w1 = 1 if q72_w1 == 1
gen newdieany_w2 = 0 if q72_w2 <= 2 | q184_w2 <= 2 
replace newdieany_w2 = 1 if q184_w2 == 1
gen newdieany_w3 = 0 if q72_w3 <= 2 | q184a_w3 <= 2 | q184b_w3 <= 2 
replace newdieany_w3 = 1 if q184a_w3 == 1 | q184b_w3 == 1
gen newdieany_w4 = 0 if q72_w4 <= 2 | q184a_w4 <= 2 | q184b_w4 <= 2 | q184c_w4 <= 2 
replace newdieany_w4 = 1 if q184a_w4 == 1 | q184b_w4 == 1 | q184c_w4 == 1
gen newdieany_w5 = 0 if q72_w5 <= 9 
replace newdieany_w5 = 1 if q72_w5 == 1 & q184_w5 == 1

********************************************************************************
** RESHAPE
********************************************************************************

keep panelnum q2_w* q3_w* q4_w* q11_w* q12_w* q13_w* q94_w* q95_w* q96_w* q97_w* q98_w* ///
q99_w* q100_w* q101_w* q102_w* q103_w* q107_w* q108_w* q109_w* q110_w* q111_w* q201_w* ///
q202_w* q203a_w* q203b_w* newcov1_w* newpay_w* newdiehh_w* newjobhh_w* newdieany_w* ///
cases_curr_w* ur_w* parishpop_w* present_w*

sort panelnum

reshape long q2_w q3_w q4_w q11_w q12_w q13_w q94_w q95_w q96_w q97_w q98_w ///
q99_w q100_w q101_w q102_w q103_w q107_w q108_w q109_w q110_w q111_w q201_w ///
q202_w q203a_w q203b_w newcov1_w newpay_w newdiehh_w newjobhh_w newdieany_w ///
cases_curr_w ur_w parishpop_w present_w, i(panelnum) j(wave)

drop if present_w == 0

********************************************************************************
** ADDITIONAL RECODES
********************************************************************************

forvalues i=2/4 {
	gen q`i'_r = 6 - q`i'_w
	}

forvalues i=11/13 {
	gen q`i'_r = 6 - q`i'_w
	}

gen q94_r = 1 if q94_w == 1
replace q94_r = 2 if q94_w == 3
replace q94_r = 3 if q94_w == 2

forvalues i=95/103 {
	gen q`i'_r = 6 - q`i'_w
	}

gen q202_r = 6 - q202_w
gen q203a_r = 6 - q203a_w
gen q203b_r = 6 - q203b_w

forvalues i=107/111 {
	gen q`i'_r = 5 - q`i'_w if q`i'_w <= 4 
	}	

	gen q201_r = 5 - q201_w if q201_w <= 4 

egen ecpol_r = rowmean(q95_r q100_r q103_r q202_r)

egen hltpol2_r = rowmean(q96_r q97_r q98_r q99_r q102_r)

egen allpol_r = rowmean(q95_r q100_r q103_r q96_r q97_r q98_r q99_r q102_r)

egen anx_hlt1 = rowmean(q2_r q3_r q4_r) 
egen anx_eco1 = rowmean(q11_r q12_r q13_r) 

gen cases_curr_pthou = cases_curr_w/(parishpop_w/1000)

gen newdieall_w = newdieany_w
replace newdieall_w = 1 if newdiehh_w == 1

tab wave, gen(wave_)
xtset panelnum wave

********************************************************************************
** COMPLETE REPLICATION FOR TABLES 1 AND 2
********************************************************************************

**Replicate table 1 column 6
xtreg anx_hlt1 newcov1_w newdieall_w cases_curr_pthou i.wave, fe
outreg2 using "table1.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 2 column 6
xtreg anx_eco1 newpay_w newjobhh_w ur_w i.wave, fe
outreg2 using "table2.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

********************************************************************************
** REPLICATE TABLE 3
********************************************************************************

**Replicate table 3 column 1
xtabond anx_hlt1 newcov1_w newdieall_w cases_curr_pthou wave_*, vce(robust)
estat abond
outreg2 using "table3.xls", stats(coef se pval) bracket(se) paren(pval) label replace dec(3)

**Replicate table 3 column 2
xtabond anx_eco1 newpay_w newjobhh_w ur_w wave_*, vce(robust)
estat abond
outreg2 using "table3.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

********************************************************************************
** COMPLETE REPLICATION OF TABLE 5 AND SUPP. TABLES 6-27
********************************************************************************

**Replicate supplementary table 6 column 4
xtreg q107_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable6.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 1 columns 5-6 and supplementary table 6 column 5
xtreg q107_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable6.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 7 column 4
xtreg q108_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable7.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 2 columns 5-6 and supplementary table 7 column 5
xtreg q108_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable7.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 8 column 4
xtreg q109_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable8.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 3 columns 5-6 and supplementary table 8 column 5
xtreg q109_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable8.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 9 column 4
xtreg q110_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable9.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 4 columns 5-6 and supplementary table 9 column 5
xtreg q110_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable9.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 10 column 4
xtreg q111_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable10.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 5 columns 5-6 and supplementary table 10 column 5
xtreg q111_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable10.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 11 column 4
xtreg q201_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable11.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)
		
**Replicate table 5 row 6 columns 5-6 and supplementary table 11 column 5
xtreg q201_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable11.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 12 column 4
xtreg q94_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable12.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 12 column 5
xtreg q94_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable12.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 13 column 4
xtreg q95_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable13.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 13 column 5
xtreg q95_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable13.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 14 column 4
xtreg q96_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable14.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 14 column 5
xtreg q96_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable14.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 15 column 4
xtreg q97_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable15.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 15 column 5
xtreg q97_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable15.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 16 column 4
xtreg q98_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable16.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 16 column 5
xtreg q98_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable16.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 17 column 4
xtreg q99_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable17.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 17 column 5
xtreg q99_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable17.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 18 column 4
xtreg q100_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable18.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 18 column 5
xtreg q100_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable18.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 19 column 4
xtreg q101_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable19.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 19 column 5
xtreg q101_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable19.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 20 column 4
xtreg q102_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable20.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 20 column 5
xtreg q102_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable20.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 21 column 4
xtreg q103_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable21.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 21 column 5
xtreg q103_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable21.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 22 column 4
xtreg q202_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable22.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 22 column 5
xtreg q202_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable22.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 23 column 4
xtreg q203a_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable23.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 23 column 5
xtreg q203a_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable23.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 24 column 4
xtreg q203b_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable24.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 24 column 5
xtreg q203b_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable24.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 25 column 4
xtreg allpol_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable25.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 9 columns 5-6 and supplementary table 25 column 5
xtreg allpol_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable25.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 26 column 4
xtreg hltpol2_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable26.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 7 columns 5-6 and supplementary table 26 column 5
xtreg hltpol2_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable26.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate supplementary table 27 column 4
xtreg ecpol_r anx_hlt1 anx_eco1 newcov1_w newdieall_w newpay_w newjobhh_w cases_curr_pthou ur_w i.wave, fe
outreg2 using "apptable27.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

**Replicate table 5 row 8 columns 5-6 and supplementary table 27 column 5
xtreg ecpol_r anx_hlt1 anx_eco1 l.anx_hlt1 l.anx_eco1 i.wave, fe
outreg2 using "apptable27.xls", stats(coef se pval) bracket(se) paren(pval) label append dec(3)

********************************************************************************
** END **
********************************************************************************
